<?php
namespace System\Controller;
use Common\Controller\AdminBaseController;
/**
 * 系统设置相关
 */
class AdminController extends AdminBaseController{

    // 系统设置主页
    public function index(){
        $server = [
            ['param' => '服务器操作系统', 'value' => PHP_OS],
            ['param' => 'web服务器环境', 'value' => $_SERVER['SERVER_SOFTWARE']],
            ['param' => 'PHP版本', 'value' => PHP_VERSION],
        ];
        $env = [
            [   'option' => 'PHP版本',
                'require' => '7.0版本以上',
                'status' => (int)compare_php('7.0.0'),
                'remark' => '版本要求'
            ]
        ];
        $auth = [
            [
                'dir' => './Runtime',
                'require' => 'Runtime目录可写',
                'status' => (int)check_dir_write('./Runtime'),
                'remark' => '运行目录'
            ],
            [
                'dir' => './upload',
                'require' => 'upload目录可写',
                'status' => (int)check_dir_write('./upload'),
                'remark' => '本地上传目录'
            ]
        ];
        $this->assign('info',['server' => $server,'env' => $env,'auth' => $auth]); //系统状态
        $this->display();
    }

    // logo设置
    public function logo(){
        $info = F('SITE_LOGO') ? F('SITE_LOGO') : ['Logo' => '','Favicon'=>'']; //在这里配置
        $this->assign('info',$info);
        $this->display();
    }

    // 存储设置
    public function storage(){
        $config = F('UPLOAD_CONFIG') ? F('UPLOAD_CONFIG') : C('UPLOAD_CONFIG'); // 优先拿出文件缓存里面的配置文件
        $this->assign('config',$config);
        $this->display();
    }

    /**
     * 2023.03.17 huhaiqin
     * 存储设置编辑
     */
    public function storage_edit(){
        C('LAYOUT_NAME','layout_layui');
        $config = F('UPLOAD_CONFIG') ? F('UPLOAD_CONFIG') : C('UPLOAD_CONFIG'); // 优先拿出文件缓存里面的配置文件
        $this->assign('config',$config);
        $this->display();
    }

    /**
     * huhaiqin，2023.03.21
     * 设置用户头像
     */
    public function avatar(){
        C('LAYOUT_NAME','layout_admin');
        $this->display('User@Admins:avatar');
    }

    /**
     * huhaiqin，2023.03.21
     * 重置密码
     */
    public function repwd(){
        // C('LAYOUT_NAME','layout_admin');
        $this->display('Admin@Config:repwd');
    }

    // seo设置
    public function seo(){
        $this->display();
    }

    // 缓存设置
    public function cache(){
        $this->display();
    }

    // 数据库备份
    public function database(){
        $this->display();
    }

    // 工具
    public function tool(){
        $this->display();
    }

    //邮件模版
    public function email(){
        $this->display();
    }
}